package qky.api.service.impl;

import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import qky.common.utils.PageUtils;
import qky.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;

import qky.api.dao.BizFirmAccountDao;
import qky.api.entity.BizFirmAccountEntity;
import qky.api.service.BizFirmAccountService;


@Component
public abstract class BizFirmAccountServiceImplGen implements BizFirmAccountService {

    @Autowired
    protected BizFirmAccountDao dao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BizFirmAccountEntity> page = this.dao.selectPage(
                new Query<BizFirmAccountEntity>().getPage(params),
                new QueryWrapper<BizFirmAccountEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public BizFirmAccountEntity query(String id) {
        return dao.selectById(id);
    }

    @Override
    public List<BizFirmAccountEntity> queryList(Map<String, Object> params) {
        return dao.queryList(params);
    }

    @Override
    public Boolean save(BizFirmAccountEntity entity) {
        return dao.insert(entity) > 0;
    }

    @Override
    public Boolean saveBatch(List<BizFirmAccountEntity> list) {
        int size = list.size();
        for (BizFirmAccountEntity entity : list) {
            size -= dao.insert(entity);
        }
        return size <= 0;
    }

    @Override
    public Boolean update(BizFirmAccountEntity entity) {
        return dao.updateById(entity) > 0;
    }

    @Override
    public Boolean updateBatch(List<BizFirmAccountEntity> list) {
        int size = list.size();
        for (BizFirmAccountEntity entity : list) {
            size -= dao.updateById(entity);
        }
        return size <= 0;
    }

    @Override
    public Boolean delete(List<String> id) {
        return dao.deleteBatchIds(id) == id.size();
    }

}
